﻿CREATE PROCEDURE [dbo].[UpdateProject]
@ProjectID INT, @Name NVARCHAR (50), @Description NVARCHAR (1024), @ManagerUserID INT, @EstCompletionDate DATETIME, @EstDuration INT, @ProjectTypeID INT, @StatusID INT, @SelectedMembers NVARCHAR (2000), @Categories NVARCHAR (4000)
AS
DECLARE @Error int
	DECLARE @TempTable TABLE(UserID int PRIMARY KEY)
	DECLARE @TempString varchar(2000)
	DECLARE @Temp varchar(4000)
	DECLARE @Count int
	DECLARE @TempCatTable TABLE(CategoryID int primary key)
	DECLARE @InnerTemp nvarchar(50)
	DECLARE @CatID int
	DECLARE @CatName varchar(20)
	DECLARE @Abbrev varchar(5)
	DECLARE @Duration decimal(10,2)
	DECLARE @InnerCount int

	BEGIN TRANSACTION 

	 
	UPDATE 
		Projects
	SET 	
		Name=@Name,
	    Description = @Description,
		ManagerUserID = @ManagerUserID,
		EstCompletionDate = @EstCompletionDate,
		EstDuration = @EstDuration,
		ProjectTypeID = @ProjectTypeID,
		StatusID = @StatusID
	       
	WHERE 
		ProjectID = @ProjectID

	SET @Error = @@ERROR
	IF @Error != 0 GOTO ERROR_HANDLER

	COMMIT TRANSACTION
	RETURN 0

ERROR_HANDLER:
	IF @@TRANCOUNT != 0 ROLLBACK TRANSACTION
	RETURN @Error

